AddScriptControl

Category: Configuration

Syntax:
AddScriptControl location edit label name [password] [= default]
AddScriptControl location check label name [transparent] [= default]
AddScriptControl location radio label name option1 [option2 option3...] [= default]
AddScriptControl location button label alias

Adds a new control to one of ViRC's "Script settings" configuration pages, optionally setting a default value. location can be config to add it to the configuration window, server to add it to servers in the server list window, or network to add it to networks in the server list window. name and alias must be a single word; label, default, and option# must be quoted.

You can retrieve the value of an option with GetSetting, GetServSetting, or GetNetSetting, depending on location.

For edit boxes, the password option can be given, which will hide the characters you type into the box.

For check boxes, the transparent option will allow a third state (grayed) in addition to checked and unchecked. The value of the option is 0 for unchecked, 1 for checked, and 2 for grayed.

For radio buttons, option1 and so on are only used for display. The value of the option is 0 if the first is chosen, 1 if the second is chosen, etc.

For regular buttons, alias will be called with $1 set to "display" to retrieve a caption for the label (set $fresult to the appropriate caption), or with $1 set to "click" when the user clicks the button. In either case, $2 will be set to the current network or server name if location is network or server, respectively.

Example:
AddScriptControl network edit "NickServ password" nickserv_passwd password
AddScriptControl config check "Show graphical smileys" smileys_enabled = 1

// use a transparent checkbox to show that a network/server option can override
// a config option
AddScriptControl config check "Respond to CTCP VERSION" ctcp_version_enabled = 1
AddScriptControl server check "Respond to CTCP VERSION" ctcp_version_enabled transparent = 2

AddScriptControl config button "Flood protection settings" floodprot_configbtn
Alias FLOODPROT_CONFIGBTN
  switch $1
    case display:
      if $FloodProtMode == 0
        @ $fresult = disabled
      else if $FloodProtMode == 1
        @ $fresult = enabled (ignore for $FloodProtIgnoreTime minutes)
      else if $FloodProtMode == 2
        @ $fresult = enabled (kickban)
      endif
    
    case click:
      // show a form to change $FloodProtMode and other options...
      _floodprot_configform
  endswitch
EndAlias

Next in "Configuration": GetPath
Next by name: AddToIAL
Previous by name: AddEventSound
Up to all commands by name or commands and functions by category